<template>
      <el-table :data="tableData" style="width: 100%" ref="tableRef">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>
  <el-button type="primary" @click="exportExcel">导出</el-button>
 
</template>


<script setup>
import {ref} from 'vue'
import { writeFile,utils } from 'xlsx';
const tableData = [
  {
    date: '2016-05-03',
    name: '',
    address: 'No. 189, Grove St, Los Angeles',
  },
  
]
const  tableRef = ref(null);

const exportExcel = () =>{
      const wb =utils.table_to_book(tableRef.value.$el);
      writeFile(wb,'table.xlsx');
    console.log('导出');
}
</script>

